
package com.meida.boot.gateway;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.meida.zuul.locator.ApiResourceLocator;
import com.meida.zuul.locator.JdbcRouteLocator;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.bus.jackson.RemoteApplicationEventScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.openfeign.EnableFeignClients;

import javax.annotation.Resource;


/**
 * 网关服务
 * 提供微服务统一外部调用入口、身份认证(@EnableResourceServer)、接口调用鉴权、接口限流、黑白名单
 * 开发环境下提供在线调试文档.
 *
 * @author zyf
 */
@EnableZuulProxy
@EnableFeignClients(basePackages = {"com.meida"})
@EnableDiscoveryClient
@SpringBootApplication(scanBasePackages = "com.meida")
@RemoteApplicationEventScan(basePackages = "com.meida")
@EnableKnife4j
public class GatewayApplication implements CommandLineRunner {
    @Resource
    private ApiResourceLocator apiResourceLocator;
    @Resource
    private JdbcRouteLocator jdbcRouteLocator;

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }

    @Override
    public void run(String... strings) throws Exception {
        jdbcRouteLocator.doRefresh();
        apiResourceLocator.refresh();
    }


}
